package lab02.test23;

/**
 * Created by JAVA on 2017/10/29.
 */
import java.util.*;

import java.io.IOException;

public class Test {
    public static void main(String[] args)   throws IOException {
        //编写Java应用程序，从命令行输入你的生日信息，然后计算你的生日还有多少天，你的生日是星期几
                Scanner sc=new Scanner(System.in);
                System.out.println("请输入你的生日：（几月几日）");
                int month=sc.nextInt() - 1;
                int day=sc.nextInt();
                Calendar birthday =Calendar.getInstance();
                birthday.set(Calendar.MONTH,month);
                birthday.set(Calendar.DATE,day);

                int weekday=birthday.get(Calendar.DAY_OF_WEEK);
                switch (weekday){
                    case 1:
                        System.out.println("你的生日是星期天");
                        break;
                    case 2:
                        System.out.println("你的生日是星期一");
                        break;
                    case 3:
                        System.out.println("你的生日是星期二");
                        break;
                    case 4:
                        System.out.println("你的生日是星期三");
                        break;
                    case 5:
                        System.out.println("你的生日是星期四");
                        break;
                    case 6:
                        System.out.println("你的生日是星期五");
                        break;
                    case 7:
                        System.out.println("你的生日是星期六");
                        break;
                }
                Calendar calendar = Calendar.getInstance();
                calendar.getTime();

                long time = (birthday.getTimeInMillis() - calendar.getTimeInMillis()) / 60 / 60 / 24 / 1000;
                if (time>=0) {
                    System.out.println("距离你的生日还有" + time + "天");
                }else {
                    System.out.println("你的生日今年已经过了哦");
                }
            }
        }

